class ChartBarEntity {
  String? aiIndex;
  String? aiIndexName;
  String? desc;
  int? all;
  int? guestId;
  String? guestLogo;
  String? guestName;
  String? guestScore;
  String? guestScoreHalf;
  String? guestScoreOt;
  int? homeId;
  String? homeLogo;
  String? homeName;
  String? homeScore;
  String? homeScoreHalf;
  String? homeScoreOt;
  int? leagueId;
  String? leagueName;
  int? level;
  int? matchId;
  String? matchTime;
  String? name;
  List<String>? option;
  int? status;
  List<String>? tips;
  List<ItemInfo>? itemInfo;
  int? suggest;

  ChartBarEntity(
      {this.aiIndex,
        this.aiIndexName,
        this.desc,
        this.all,
        this.guestId,
        this.guestLogo,
        this.guestName,
        this.guestScore,
        this.guestScoreHalf,
        this.guestScoreOt,
        this.homeId,
        this.homeLogo,
        this.homeName,
        this.homeScore,
        this.homeScoreHalf,
        this.homeScoreOt,
        this.leagueId,
        this.leagueName,
        this.level,
        this.matchId,
        this.matchTime,
        this.name,
        this.option,
        this.status,
        this.tips,
        this.suggest,
        this.itemInfo});

  ChartBarEntity.fromJson(Map<String, dynamic> json) {
    aiIndex = json['aiIndex'];
    aiIndexName = json['aiIndexName'];
    all = json['all'];
    desc = json['desc'];
    guestId = json['guestId'];
    guestLogo = json['guestLogo'];
    guestName = json['guestName'];
    guestScore = json['guestScore'];
    guestScoreHalf = json['guestScoreHalf'];
    guestScoreOt = json['guestScoreOt'];
    homeId = json['homeId'];
    homeLogo = json['homeLogo'];
    homeName = json['homeName'];
    homeScore = json['homeScore'];
    homeScoreHalf = json['homeScoreHalf'];
    homeScoreOt = json['homeScoreOt'];
    leagueId = json['leagueId'];
    leagueName = json['leagueName'];
    level = json['level'];
    matchId = json['matchId'];
    matchTime = json['matchTime'];
    name = json['name'];
    option = json['option']?.cast<String>();
    status = json['status'];
    tips = json['tips']?.cast<String>();
    if (json['itemInfo'] != null) {
      itemInfo = <ItemInfo>[];
      json['itemInfo'].forEach((v) {
        itemInfo!.add(new ItemInfo.fromJson(v));
      });
    }
    suggest = json['suggest'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['aiIndex'] = this.aiIndex;
    data['aiIndexName'] = this.aiIndexName;
    data['all'] = this.all;
    data['desc'] = this.desc;
    data['guestId'] = this.guestId;
    data['guestLogo'] = this.guestLogo;
    data['guestName'] = this.guestName;
    data['guestScore'] = this.guestScore;
    data['guestScoreHalf'] = this.guestScoreHalf;
    data['guestScoreOt'] = this.guestScoreOt;
    data['homeId'] = this.homeId;
    data['homeLogo'] = this.homeLogo;
    data['homeName'] = this.homeName;
    data['homeScore'] = this.homeScore;
    data['homeScoreHalf'] = this.homeScoreHalf;
    data['homeScoreOt'] = this.homeScoreOt;
    data['leagueId'] = this.leagueId;
    data['leagueName'] = this.leagueName;
    data['level'] = this.level;
    data['matchId'] = this.matchId;
    data['matchTime'] = this.matchTime;
    data['name'] = this.name;
    data['option'] = this.option;
    data['status'] = this.status;
    data['tips'] = this.tips;
    if (this.itemInfo != null) {
      data['itemInfo'] = this.itemInfo!.map((v) => v.toJson()).toList();
    }
    data['suggest'] = this.suggest;
    return data;
  }
}

class ItemInfo {
  String? info;
  String? name;
  double? rate;

  ItemInfo({this.info, this.name, this.rate});

  ItemInfo.fromJson(Map<String, dynamic> json) {
    info = json['cnt'];
    name = json['name'];
    rate = json['ratio'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['cnt'] = this.info;
    data['name'] = this.name;
    data['ratio'] = this.rate;
    return data;
  }
}

extension MaxExtension on List<ItemInfo>? {
  int get max {
    var index = 0;
    if((this?.length ?? 0) > 1) {
      for (var i = 0; i < this!.length - 1; i++) {
        if((this![i].rate ?? 0) < (this![i+1].rate ?? 0)) index = i+1;
      }
      return index;
    }else{
      return index;
    }
  }
}

class Suggest {
  Option? asia;
  Option? europe;
  Option? faith;

  Suggest({this.asia, this.europe,this.faith});

  Suggest.fromJson(Map<String, dynamic> json) {
    asia = json['asia'] != null ? new Option.fromJson(json['asia']) : null;
    europe = json['europe'] != null ? new Option.fromJson(json['europe']) : null;
    faith = json['trader'] != null ? new Option.fromJson(json['trader']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.asia != null) {
      data['asia'] = this.asia!.toJson();
    }
    if (this.europe != null) {
      data['europe'] = this.europe!.toJson();
    }
    if (this.faith != null) {
      data['trader'] = this.faith!.toJson();
    }
    return data;
  }
}

class Option {
  Od? od;
  double? cnt;

  Option({this.od, this.cnt});

  Option.fromJson(Map<String, dynamic> json) {
    od = json['od'] != null ? new Od.fromJson(json['od']) : null;
    cnt = json['cnt'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.od != null) {
      data['od'] = this.od!.toJson();
    }
    data['cnt'] = this.cnt;
    return data;
  }
}

class Od {
  String? s;
  String? p;
  String? f;

  Od({this.s, this.p, this.f});

  Od.fromJson(Map<String, dynamic> json) {
    s = json['s'];
    p = json['p'];
    f = json['f'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['s'] = this.s;
    data['p'] = this.p;
    data['f'] = this.f;
    return data;
  }
}
